<?php
/*
 * ebiz front
 *
 * userinfo Controller
 *
 * @author 
 *
 */
require_once '../app/core/controllers/BaseController.php';
require_once '../app/util/CommonUtil.php';
require_once '../app/util/Pager.php';
require_once '../app/constants/ConfigConstants.php';
require_once '../app/services/AreaService.php';
require_once '../app/services/UserInfoService.php';
require_once '../app/services/AAService.php';
require_once '../app/services/CustomerService.php';
require_once '../app/services/QueryService.php';
require_once '../app/services/OrderService.php';
require_once '../app/services/UserPointService.php';
require_once '../app/services/AgentAccountService.php';
require_once "../". $GLOBALS["local"] ."/"."myaccount.php";
require_once '../app/constants/Order.php';
require_once '../app/constants/AgentAccount.php';
require_once '../app/views/MyAccoutLeftNavView.php';
require_once '../app/services/VoteService.php';
require_once '../app/services/ProductService.php';
require_once '../app/services/ApplyGiftService.php';

require_once '../app/services/EmailService.php';

require_once '../app/constants/ConfigConstants.php';
require_once '../app/component/MailUtil.php';

class UserInfoController extends BaseController {


    public function index(){
        $userId = AAService::getCustomer();
        $customerService = new CustomerService();
        $userInfo = $customerService->getCustomerById($userId);
        if($userInfo[0]['certf'] == 3){
        	$agentAccountService = new AgentAccountSercive();
        	$agentAccountInfo = $agentAccountService->getAccountAgentTotalByUserId($userInfo[0]['id']);
        }
        require_once '../app/views/UserIndexView.php';
        $userIndexView = new UserIndexView();
        echo $userIndexView->getPage($userInfo,$agentAccountInfo);
    }
    public function modifypassword(){

        CommonUtil::startTimeFunction();
        AAService::isLogin(true);
        $config = $GLOBALS["config"];
        require_once "../". $GLOBALS["local"] ."/"."utility.php";
   //     require_once '../app/controllers/ImageController.php';
   //     $imageController = new ImageController();
   //     $captchaImg = $imageController->indexAction();
        require_once '../app/views/ModifyPasswordView.php';
        $modifyPswView = new ModifyPasswordView();
        echo $modifyPswView->getPage();
        exit();
    }

    public function delivery(){
    	AAService::isLogin(true);
    	$config = $GLOBALS["config"];
        $userId = AAService::getCustomer();
        $userInfoService = new UserInfoService();
        $deliveryLists = $userInfoService->getDeliveryList(($userId));
        require_once '../app/views/DeliveryListView.php';
        require_once '../app/views/DeliveryView.php';
        $deliveryView = new DeliveryView();
        echo $deliveryView->getPage($deliveryLists);

    }

    public function editdelivery(){
    	AAService::isLogin(true);
    	$config = $GLOBALS["config"];
        $id = HttpUtil::getPostString('id');
        $userInfoService = new UserInfoService();
        $curDelivery = $userInfoService->getDeliveryById($id);

        $areaService = new AreaService();
        $param1 = array($curDelivery[0]['address_1'],2);
        $cities = $areaService->getAreaDicts($param1);
        $param2 = array($curDelivery[0]['address_2'],3);
        $counties = $areaService->getAreaDicts($param2);

        array_push($curDelivery,$cities);
        array_push($curDelivery,$counties);


        echo json_encode($curDelivery);
        exit;

    }

    public function deldelivery(){
        AAService::isLogin(true);
        $id = HttpUtil::getPostString('id');
        $userInfoService = new UserInfoService();
        $userInfoService->delDelivery($id);
        echo json_encode($id);
        exit();

    }

    public function updateaddress(){
    	AAService::isLogin(true);
        $userId = AAService::getCustomer();
        $customerService = new CustomerService();
        $userInfo = $customerService->getCustomerById($userId);

        require_once '../app/views/UpdateAddressView.php';
        $updateAddrView = new UpdateAddressView();
        echo $updateAddrView->getPage($userInfo);

    }
    
    public function mycomment(){
    	AAService::isLogin(true);
        $config = $GLOBALS['config'];
        $int_userid = AAService::getCustomer();
        
        $int_page = 0;
        $int_limit = $GLOBALS['config']['items_per_page'];
        $int_nowPage = 1;
        if( !empty( $GLOBALS['config']['urlparam'][3] ) ){
            $int_nowPage = intval( $GLOBALS['config']['urlparam'][3] );
        }
        if( $int_nowPage > 1 ){
            $int_page = $int_nowPage - 1;
        }
        
        $voteService = new VoteService();
        $arr_comments = $voteService->getCommentsByUserId( $int_userid, $int_page, $int_limit );

        $arr_output = array(
            'pager' => array(
                'countrows' => $arr_comments['Count'],
                'nowpage' => $int_nowPage,
                'prepage' => $int_limit
            ),
            'rows' => $arr_comments
        );

        if (isset($arr_output['rows']['Count'])) {
        	unset($arr_output['rows']['Count']);
        }
        //print_r($arr_comments);exit;
        require_once '../app/views/MyCommentView.php';
       
        exit;
    	
    }

    /**
     * User query list
     *
     * @author by M.Wang
     */
    public function myquery(){
    	AAService::isLogin(true);
        $config = $GLOBALS['config'];
        $int_userid = AAService::getCustomer();
        $customerService = new CustomerService();
        $arr_userInfo = $customerService->getCustomerById($int_userid);
        $int_page = 0;
        $int_limit = $GLOBALS['config']['items_per_page'];
        $int_nowPage = 1;
        if( !empty( $GLOBALS['config']['urlparam'][3] ) )
            $int_nowPage = intval( $GLOBALS['config']['urlparam'][3] );
        if( $int_nowPage > 1 )
            $int_page = $int_nowPage - 1;
        $queryService = new QueryService();

        $arr_querys = $queryService->getQuerysByUserId( $int_userid, $int_page, $int_limit );

        $arr_output = array(
            'pager' => array(
                'countrows' => $arr_querys['Count'],
                'nowpage' => $int_nowPage,
                'prepage' => $int_limit
            ),
            'rows' => $arr_querys
        );

        if (isset($arr_output['rows']['Count'])) {
        	unset($arr_output['rows']['Count']);
        }

        require_once '../app/views/MyQueryView.php';
        $myQueryView = new MyQueryView();
        echo $myQueryView->getMyQueryPage($arr_output);
        exit;

    }

    /**
     * Show reply message
     *
     * @author by M.Wang
     */
    public function showquery(){
        AAService::isLogin(true);
        require_once "../". $GLOBALS["local"] ."/"."myaccount.php";
        $int_queryid = $GLOBALS['config']['urlparam'][3];
        $queryService = new QueryService();
        $arr_query = $queryService->getQueryById( $int_queryid );
        $arr_reply = $queryService->getReplyByQueryId( $int_queryid );

        require_once "../". $GLOBALS["local"] ."/"."myaccount.php";
        require_once '../app/views/ShowQueryView.php';
    }

    /**
     * Display my orders view
     *
     * @author by M.Wang
     */
    public function myorderlist(){
        self::schoolOrderList( true );
    }

    /**
     * Display school order view
     *
     * @author by M.Wang
     */
    public function schoolorderlist( $bool_selfModel = false ){
    	AAService::isLogin(true);
        /**
    	 * 对于个人模式，选择agent_id为0的订单 isSuperAgent 为false
    	 * 对于校园大使，选择agent_id为user_id的订单 isSuperAgent 为True
    	 * 对于校园代理，选择agent_id为user_id的parent_id的订单 isSuperAgent 为false
         */
    	$int_userid = AAService::getCustomer();
    	$customerService = new CustomerService();
    	$arr_user = $customerService->getCustomerById($int_userid);
    	$arr_user = $arr_user[0];
    	$config = $GLOBALS['config'];
        /**
         * Get super agent id
         */
    	$bool_isSuperAgent = false;
        if(!$bool_selfModel){
        	if( $arr_user['parent_id'] < 1 ){
                $int_sagentid = $int_userid;
                $bool_isSuperAgent = true;
        	}else{
        	   $int_sagentid = $arr_user['parent_id'];
        	}
        }

    	/**
    	 * Make other condition
    	 */
    	  $arr_select = array();
        $str_otherCondition = '';
        $arr_select['liveOrder'] = HttpUtil::getPostValue( 'liveOrder' );
        if( $arr_select['liveOrder'] > 1 ){
        	switch ( $arr_select['liveOrder'] ){
        		case 2: $str_otherCondition = ' AND `o`.`status` IN (1,2,3,4,11,12,13,14,21,22,23,24) AND `o`.`is_returned` < 1'; break;
                case 3: $str_otherCondition = ' AND `o`.`status` IN (5,15,25)'; break;
                case 4: $str_otherCondition = ' AND `o`.`status` IN (6,16,26)'; break;
        	    case 5: $str_otherCondition = ' AND ( `o`.`status` IN (7,17,27)  OR `o`.`is_returned` > 0 )'; break;
        	}
        }else{
            $arr_select['liveOrder'] = 1;
        }
        //$arr_select['liveOrder'] = 1;
        $arr_select['order_id'] = HttpUtil::getPostString( 'order_id' );
        if( $arr_select['order_id'] )
           $str_otherCondition.= " AND `o`.`id` LIKE '{$arr_select['order_id']}%'";
        $arr_select['product_name'] = HttpUtil::getPostString( 'product_name' );
        if( $arr_select['product_name'] )
           $str_otherCondition.= " AND `p`.`title` LIKE '%{$arr_select['product_name']}%'";
        $arr_select['order_status'] = HttpUtil::getPostString( 'order_status' );
        if( $arr_select['order_status'] )
           $str_otherCondition.= " AND `o`.`status` = '{$arr_select['order_status']}'";
        $arr_select['order_createdd'] = HttpUtil::getPostString( 'order_createdd' );
        if( $arr_select['order_createdd'] )
           $str_otherCondition.= " AND `o`.`created` >= '{$arr_select['order_createdd']}'";
        $arr_select['order_createdu'] = HttpUtil::getPostString( 'order_createdu' );
        if( $arr_select['order_createdu'] )
           $str_otherCondition.= " AND `o`.`created` <= '{$arr_select['order_createdu']}'";

    	/**
    	 * Make page limit
    	 */
        $int_limit = Pager::GetDefaultPagesize();
        $int_nowPage = HttpUtil::getPostValue( 'page' );

    	/**
    	 * Get orders
    	 */
        $orderService = new OrderService();
        if( $bool_selfModel )
            $int_countrows = $orderService->getOrdersCountRowsByUserId($int_userid, $str_otherCondition);
        else
            $int_countrows = $orderService->getOrdersCountRowsBySuperAgentId($int_sagentid, $str_otherCondition);
        Pager::ValidateNowPage($int_nowPage, $int_countrows);

        if( $bool_selfModel )
            $arr_orders = $orderService->getOrdersByUserId( $int_userid, Pager::GetPageLimitStartNumber($int_nowPage), $int_limit, $str_otherCondition );
        else
            $arr_orders = $orderService->getOrdersBySuperAgentId( $int_sagentid, Pager::GetPageLimitStartNumber($int_nowPage), $int_limit, $str_otherCondition );

        /**
         * Get order items
         */
        if( $arr_orders ){
        	foreach ( $arr_orders as $int_key => $arr_order ){
        		$arr_items = $orderService->getOrderItemInfoByOrderIdByWang( $arr_order['id'] );
        		if( !empty( $arr_items ) )
        		  $arr_orders[$int_key]['items'] = $arr_items;
        	}
        }

        require_once '../app/views/OrderListSchoolView.php';

        $orderListView = new OrderListView($bool_selfModel);
        $orderListView->userid = $int_userid;
        $orderListView->isSuperAgent = $bool_isSuperAgent;
        $orderListView->orders = $arr_orders;
        $orderListView->orderStatus = Order::getOrderStatusFront();
        $orderListView->formdata = $arr_select;
        $orderListView->pager = array('nowpage'=>$int_nowPage, 'countrows'=>$int_countrows, 'pageLimit'=>$int_limit);
        echo $orderListView->getPage();

    }

    /**
     * Last page will tell us the order's new step, do it and return right or faild.
     *
     * @author by M.Wang
     */
    public function nextstep(){
        AAService::isLogin(true);
        $config = $GLOBALS["config"];
        require_once "../". $GLOBALS["local"] ."/"."utility.php";
        require_once "../". $GLOBALS["local"] ."/"."common.php";
        $int_userid = AAService::getCustomer();
    	$int_orderid = HttpUtil::getPostValue( 'order_id' );
    	$int_requestNextStep = HttpUtil::getPostValue( 'order_status' );
        $orderService = new OrderService();
        $arr_order = $orderService->getOrderInfoById($int_orderid);
        //发邮件的订单信息
        $orderInfo = $arr_order;
        $orderItemInfo = $orderService->getOrderItemInfoByOrderId($int_orderid);
        
       if( !empty($arr_order[0]) )
           $arr_order = $arr_order[0];

        if( !empty($arr_order) ){
            //给相应用户发确认信
	        $userId =  $orderInfo[0]["user_id"];//得到下单用户id
            $agentId = $orderInfo[0]["agent_id"];//得到送货大使ID
	        $customerService = new CustomerService();
	        $userInfo = $customerService->getUserCertfByUserId($userId);
	        $username = $userInfo[0]["name"];//得到下单用户name
	        $userEmail = $userInfo[0]["email"];//得到下单用户email
	        $userCertf = $userInfo[0]["certf"];//得到下单用户类型
	        $userStatus = $userInfo[0]["status"];//得到下单用户状态
	        $agentUserInfo = $customerService->getUserCertfByUserId($agentId);//得到大使信息
	        $agentUserName = $agentUserInfo[0]["name"];//得到大使name
	        $agentTeamName = $agentUserInfo[0]["team_name"];//得到大使team name
            $agentUserEmail = $agentUserInfo[0]["email"];//得到大使email
            $agentUserCampusId = $agentUserInfo[0]["campus_id"];//得到大使所在学校的ID
//            $agentUserStatus = $agentUserInfo[0]["status"];//得到大使的状态
        	$int_nextStatus = $orderService->getOrdersNextStatus($arr_order,$int_userid,$int_requestNextStep);
        	$str_message = '';
        	
        	/**
        	 * 调用相应的处理
        	 */
        	if( $int_nextStatus > 0 ){
            	$bool_isRight = false;
            	switch ( $int_nextStatus ){
            		case 3:
            		    //支付网关介入
            		    break;
            		case 4:
            		    //非用户介入
            		    break;
             		case 5:
             		    //可选的用户介入
            			break;
            		case 6:
            		    //如果当前状态小于3可以取消订单
            		    if($arr_order['status'] && $arr_order['status']<3)
            		      $bool_isRight = $orderService->returnInventory($int_orderid);
            			break;
            		case 7:
            		    //退货处理
            		    if($arr_order['status']>2 && $arr_order['status']<5)
            		      $bool_isRight = $orderService->setOrderReturned($int_orderid,1);
            			break;
            		case 12:
            		    //校园大使确认订单并扣除相应款项
            		      $bool_isRight = $orderService->freezeMoney($arr_order['agent_id'],$arr_order['total'],31,$arr_order['order_num'],$int_orderid,$GLOBALS['_SESSION']['uname']);
            		      if(!$bool_isRight){//大使余额不足
            		          $str_message = 'ORDERPAYMENTERR1201';
            		      }else{//确认订单
            		      	
            		      	   //发邮件确认
                                   $result = array( "orderInfo" => $orderInfo, 
                                             "orderItemInfo" => $orderItemInfo, 
                                             "username" => $username, 
                                             "userEmail" => $userEmail, 
                                             "agentUserEmail" => $agentUserEmail, 
                                             "agentUserName" => $agentUserName, 
                                             "agentTeamName" => $agentTeamName, 
                                             "agentUserCampusId" => $agentUserCampusId );
                                   $emailService = new EmailService();
                                   $emailTitle = ORDERCONFIRMATION;//邮件title
                                   $emailBodyToUser = $emailService->orderConfirmationEmailToUser($result);//获得邮件主体内容
                                   $emailBodyToAmbassador = $emailService->orderConfirmationEmailToAmbassador($result);//获得邮件主体内容
            		      	   if(AAService::isLogin() && !empty($userStatus) ){ 
			                       MailUtil::sendMail($userEmail, $emailTitle, $emailBodyToUser);
            		      	   }
            		      	   MailUtil::sendMail($agentUserEmail, $emailTitle, $emailBodyToAmbassador);
            		      }
            			break;
            		case 13:
            		    //校园大使确认已收到商品
            		    if(AAService::isLogin() && !empty($userStatus)){ 
	            		    //发邮件确认
	            			$result = array( "orderInfo" => $orderInfo, 
	                                         "orderItemInfo" => $orderItemInfo, 
	                                         "email" => $userEmail, 
	                                         "username" => $username );
	                        $emailService = new EmailService();
	                        $emailTitle = CAMPUSRECEIPT;//邮件title
	                        $emailBodyToUser = $emailService->orderReceiptEmailToUser($result);//获得邮件主体内容
	                        if($userCertf == 1){
	                            MailUtil::sendMail($userEmail, $emailTitle, $emailBodyToUser);
	                        }
            		    }
            		    
            		    $bool_isRight = true;
            			break;
            		case 14:
            		    //非用户介入
            			break;
            		case 15:
            		    //非用户介入
            			break;
            		case 16:
            		    //如果当前状态为11可以取消订单
            		    if($arr_order['status'] && $arr_order['status']=='11')
            		      $bool_isRight = $orderService->returnInventory($int_orderid);
            			break;
            		case 17:
            		    //退货处理
            		    if($arr_order['status']>11 && $arr_order['status']<15)
            		      $bool_isRight = $orderService->setOrderReturned($int_orderid,1);
            			break;
            		default:
            			break;
            	}

            	if( $bool_isRight ){
            		/**
            		 * save data
            		 */
            		$orderService = new OrderService();
            		if( !empty($int_requestNextStep) && $int_requestNextStep % 10 == 7 )
            		    $int_nextStatus = $arr_order['status'];
            		if( $orderService->updateOrderStatus( $int_orderid, $int_nextStatus, $int_userid ) ){
        				header( 'Location:/userinfo/showorder/' . $int_orderid );
        				exit;
            		}
            	}
        	}
        }

    	/**
    	 * Throw exception
    	 */
        require_once '../app/views/ErrorMessageView.php';
        $errorMessageView = new ErrorMessageView();
        echo $errorMessageView->getPage($str_message);
        exit;

    }

    /**
     * Show order detail
     *
     * @author by M.Wang
     */
    public function showorder(){
    	AAService::isLogin(true);
    	$int_userid = AAService::getCustomer();
    	$customerService = new CustomerService();
    	$arr_user = $customerService->getCustomerById($int_userid);
    	$arr_user = $arr_user[0];
    	$config = $GLOBALS['config'];
        $int_userid = AAService::getCustomer();
    	$int_orderid = $GLOBALS['config']['urlparam'][3];

    	/**
    	 * Get order data
    	 */
    	$orderService = new OrderService();
    	$arr_order = $orderService->getOrderInfoById( $int_orderid );
    	if(empty($arr_order[0]))
    	   HttpUtil::renderError(EINVALIDORDERID);
    	$arr_order = $arr_order[0];
    	if(!empty($arr_order['is_returned']))
    	   $arr_order['status'] = floor($arr_order['status'] / 10) * 10 + 7;
    	$arr_orderitems = $orderService->getPackageInfoByOrderId( $int_orderid );

        /**
         * 如果订单的agent_id为0 user_id等于当前用户的user_id isSuperAgent = true
         * 如果订单的agent_id非0 agent_id等于当前用户的user_id isSuperAgent = true
         */
    	$bool_isSuperAgent = false;
    	if( $arr_order['agent_id'] < 1 && $arr_order['user_id'] == $int_userid )
    	   $bool_isSuperAgent = true;
    	elseif( $arr_order['agent_id'] == $int_userid )
    	   $bool_isSuperAgent = true;

        require_once '../app/views/ShowOrderView.php';
        $showOrderView = new ShowOrderView();
        $showOrderView->order = $arr_order;
        $showOrderView->items = $arr_orderitems;
        $showOrderView->userid = $int_userid;
        $showOrderView->isSuperAgent = $bool_isSuperAgent;
        echo $showOrderView->getPage();
    }

    /**
     * Show user point update history
     *
     * @author by M.Wang
     */
    public function mybuyerpointlist(){
    	AAService::isLogin(true);
        $int_userid = AAService::getCustomer();
        $customerService = new CustomerService();
        $arr_user = $customerService->getCustomerById($int_userid);
        $arr_user = $arr_user[0];

        /**
         * Make page limit
         */
        $int_page = 0;
        $int_limit = $GLOBALS['config']['items_per_page'];
        $int_nowPage = $GLOBALS['config']['urlparam'][3];
        if( $int_nowPage > 1 )
            $int_page = $int_nowPage - 1;
        else
                $int_nowPage = 1;

        $userPointService = new UserPointService();
        $arr_logs = $userPointService->getUserPointLogs($int_userid,$int_page,$int_limit);
        require_once '../app/views/BuyerPointListView.php';
        $buyerPointListView = new BuyerPointListView();
        $buyerPointListView->nowpage = $int_page + 1;
        $buyerPointListView->user = $arr_user;
        $buyerPointListView->logs = $arr_logs;
        echo $buyerPointListView->getPage();
        exit;
    }
    
    /**
     * 兑换中心
     */
    public function exchangecenter(){
    	AAService::isLogin(true);
    	$config = $GLOBALS["config"];
    	$int_userid = AAService::getCustomer();
        $customerService = new CustomerService();
        $arr_user = $customerService->getCustomerById($int_userid);
        $arr_user = $arr_user[0];
        $pointsBuyer = $arr_user["points_buyer"];
        $pointsBuyerTotal = $arr_user["points_buyer_total"];
        //兑换礼品部分
        $applyGiftService = new ApplyGiftService();
        $giftProductInfo = $applyGiftService->getGiftProductInfo();
        $queryAllNum = $applyGiftService->getAllNum();
        //生成兑换礼品部分分页html
        $pager = new Pager();
        $pager->setJavascriptFunction("javascript:ExchangeContent.ajaxPaginate");
        $itemsPerPage = $GLOBALS["config"]['items_per_page'];//akimimi set is 20
        $headerPaginate = $pager->paginate(1, $queryAllNum, "", $itemsPerPage);
        
        //兑换抵用券部分
        $promotionInfo = $applyGiftService->getExchangePromotion();
        
        
        require_once '../app/views/ExchangeCenterView.php';
        
    	exit;
    }
    
    /**
     * 显示礼品列表页面
     */
    public function exchangegiftlist(){
    	AAService::isLogin(true);
    	$applyGiftService = new ApplyGiftService();
    	$exchangeInfo = $applyGiftService->showExchangeInfo();
    	//生成分页html
    	$logsAllNumber = $applyGiftService->getAllNumber();
        $pager = new Pager();
        $pager->setJavascriptFunction("javascript:ExchangeContent.ajaxGiftPaginate");
        $itemsPerPage = $GLOBALS["config"]['items_per_page'];//akimimi set is 20
        $headerPaginate = $pager->paginate(1, $logsAllNumber, "", $itemsPerPage);
        
    	require_once '../app/views/ExchangeGiftListView.php';
        exit;
    }
 
 // Steve 礼品详情页面  
    public function giftdetail(){
    	AAService::isLogin(true);
    	$config = $GLOBALS["config"];
    	$applyGiftLogId = HttpUtil::getGetValue('id');
    	$giftService = new ApplyGiftService();
    	$applyGiftLog = $giftService->getApplyLogById($applyGiftLogId);
    	if($applyGiftLog[0]['apply_type'] == 1){
    		$promotion = $giftService->getPromotionInfoById($applyGiftLog[0]['promotion_id']);
    	} else if($applyGiftLog[0]['apply_type'] == 2){
    		$gift = $giftService->getGiftById($applyGiftLog[0]['gift_id']);
    		$areaService = new AreaService();
    		$province = $areaService->getAreaById($applyGiftLog[0]['delivery_address1']); 
    		$city = $areaService->getAreaById($applyGiftLog[0]['delivery_address2']); 
    		$county = $areaService->getAreaById($applyGiftLog[0]['delivery_address3']); 
    		
    	}
    	require_once '../app/views/GiftDetailView.php';
        exit;
    	
    }
    
    /**
     * 显示wishlist列表页面
     */
    public function userwishlist(){
    	AAService::isLogin(true);
    	$config = $GLOBALS["config"];
        require_once "../". $GLOBALS["local"] ."/"."common.php";
        $userInfoService = new UserInfoService();
        $wishlistInfo = $userInfoService->getUserWishlistInfoByUserId();
        //生成第一页html
        $wishlistAllNumber = $userInfoService->getWishlistAllNumber();
        $pager = new Pager();
        $pager->setJavascriptFunction("javascript:WishlistContent.ajaxWishlistPaginate");
        $itemsPerPage = $GLOBALS["config"]['items_per_page'];//akimimi set is 20
        $headerPaginate = $pager->paginate(1, $wishlistAllNumber, "", $itemsPerPage);
        require_once '../app/views/WishlistView.php';
        exit;
    }
    

}